package com.jwm.power.controller;

import com.jwm.power.model.reponse.ResponseData;
import com.jwm.power.service.OperateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;

//  数据操作类
@Controller
@RequestMapping("/operate")
public class OperateController {
    @Autowired
    private OperateService operateService;
    //  删除数据
    @RequestMapping(value = "deleteDatas", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData DeleteDatas(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.DeleteDatas(request);
    }
    //  批量删除数据
    @RequestMapping(value = "deleteAllDatas", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData DeleteAllDatas(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.DeleteAllDatas(request);
    }
    //  设置数据排序
    @RequestMapping(value = "setDataSn", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData SetDataSn(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.SetDataSn(request);
    }
    //  阅读公告
    @RequestMapping(value = "readNotices", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData ReadNotices(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.ReadNotices(request);
    }
    //  数据提交
    @RequestMapping(value = "submitDatas", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData SubmitDatas(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.SubmitDatas(request);
    }
    // 撤销表单
    @RequestMapping(value = "takebackDatas", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData TakebackDatas(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.TakebackDatas(request);
    }
    // 完成表单
    @RequestMapping(value = "ComplateDatas", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData ComplateDatas(HttpServletRequest request, HttpServletResponse response) throws ParseException {
        return operateService.ComplateDatas(request);
    }
}
